package TextOne;

import java.util.Scanner;

public class Date {

    int year,month,date;
    public Date(int year,int month,int date) {
        this.year=year;
        this.month=month;
        this.date=date;
    }
    public void GetDate() {
        System.out.print("当前日期是："+ year +"."+month+"."+date+'\n');
    }
    public void UpDate() {

        int x = 0;
        if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
            x=31;
        if(month==4||month==6||month==9||month==11)
            x=30;
        if(month==2){
            if(year%4==0&&year%100!=0||year%400==0)
                x=29;
            else
                x=28;
        }
        date=date+1;
        if(date>x)
        {
            month=month+1;
            date=date-x;
            if(month>12)
            {
                year=year+1;
                month=month-12;
            }
        }
        System.out.print("当前日期的下一天是："+ year +"."+month+"."+date+'\n');
    }
    public static void main(String[] args) {
        System.out.println("请分别输入年、月、日");
        Scanner newInput =new Scanner(System.in);
        System.out.println("年：");
        int y=newInput.nextInt();
        System.out.println("月：");
        int m=newInput.nextInt();
        System.out.println("日：");
        int d=newInput.nextInt();
        if(y<1||y>2050||m<1||m>20||d<1||d>31) {
            System.out.println("参数输入非法！");
            System.exit(0);
        }
        if((m==1||m==3||m==5||m==7||m==8||m==10||m==12)&&d>31) {
            System.out.println("不可能");
            System.exit(0);
        }
        if((m==4||m==6||m==9||m==11)&&d>30) {
            System.out.println("不可能");
            System.exit(0);
        }
        if(m==2){
            if((y%4==0&&y%100!=0||y%400==0)) {
                if(d>29) {
                    System.out.println("不可能");
                    System.exit(0);
                }
            }
            else {
                if(d>28) {
                    System.out.println("不可能");
                    System.exit(0);
                }
            }
        }
        Date myDate=new Date(y,m,d);
        myDate.GetDate();
        myDate.UpDate();
    }
}